package com.example.secondhandsysapi.Mapper;

import com.example.secondhandsysapi.Entity.ActionLogInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface ActionLogInfoMapper {

    @Delete("delete from action_log where act_id=#{act_id}")
    Integer deleteByID(Integer act_id);

    @Select("SELECT * FROM action_log WHERE act_outcome like CONCAT('%', #{act_outcome}, '%') and user_id=#{user_id}")
    List<ActionLogInfo> getAllActionLogInfoOutcomeId(@Param("act_outcome") String act_outcome, @Param("user_id")Integer user_id);

    @Select("SELECT * FROM action_log WHERE act_outcome like '%${act_outcome}%'")
    List<ActionLogInfo> getAllActionLogInfoOutcome(String act_outcome);

    @Select("SELECT * FROM action_log WHERE user_id =#{user_id}")
    List<ActionLogInfo> getAllActionLogInfoUserId(Integer user_id);

    @Select("SELECT * FROM action_log WHERE act_time like '%${act_time}%'")
    List<ActionLogInfo> getAllActionLogInfoTime(Date act_time);

    @Select("SELECT * FROM action_log")
    List<ActionLogInfo> getAllActionLogInfo();

    @Select("SELECT * FROM action_log WHERE act_outcome like CONCAT('%', #{act_outcome}, '%') and act_time like CONCAT('%', #{act_time}, '%')")
    List<ActionLogInfo> getAllActionLogInfoOutcomeTime( @Param("act_outcome") String act_outcome,@Param("act_time") Date act_time);

    @Select("SELECT * FROM action_log WHERE user_id=#{user_id} and act_time like CONCAT('%', #{act_time}, '%')")
    List<ActionLogInfo> getAllActionLogInfoUserIdTime(@Param("user_id")Integer user_id,@Param("act_time") Date act_time);

    @Select("SELECT * FROM action_log WHERE user_id=#{user_id} and act_outcome like  CONCAT('%', #{act_outcome}, '%') and act_time like  CONCAT('%', #{act_time}, '%')")
    List<ActionLogInfo> getAllActionLogInfoUserIdOutcomeTime(@Param("user_id") Integer user_id,@Param("act_outcome") String act_outcome,@Param("act_time") Date act_time);

    List<ActionLogInfo> getAllActionLogInfoTime(String formatStr);
}



